//
//  SettingViewController.m
//  PhotoBook
//
//  Created by Classic on 12/10/12.
//  Copyright (c) 2012 Hoang tuan. All rights reserved.
//

#import "SettingViewController.h"


@implementation SettingViewController
@synthesize listData;


- (void)viewDidLoad
{
	// Do any additional setup after loading the view.
    NSArray *array = [[NSArray alloc] initWithObjects:@"iPhone", @"iPod", @"iPad",@"imac",@"macbook pro", @"macbook air",nil];
	self.listData = array;
	[array release];
	[super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
	[listData dealloc];
    [_listView release];
    [super dealloc];
}

#pragma mark -
#pragma mark Table View Data Source Methods


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
	return [self.listData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	static NSString *SimpleTableIdentifier = @"SettingIdentifier";
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
	if (cell == nil) { cell = [[[UITableViewCell alloc]
								initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
	}
	NSUInteger row = [indexPath row]; cell.textLabel.text = [listData objectAtIndex:row];
    if(indexPath.row % 2 != 0){
        cell.contentView.backgroundColor = [self colorFromHexString:@"#F2F2F2"];
        cell.textLabel.backgroundColor = [self colorFromHexString:@"#F2F2F2"];
    }
    return cell;
	
}
-(UIColor *)colorFromHexString:(NSString *)hexString {
    unsigned rgbValue = 0;
    NSScanner *scanner = [NSScanner scannerWithString:hexString];
    [scanner setScanLocation:1]; // bypass '#' character
    [scanner scanHexInt:&rgbValue];
    return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
}
@end
